﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; 
using NTTDATA.BEENChina.ResultCertification.Config; 

namespace NTTDATA.BEENChina.ResultCertification.Checker.Select
{
   
    [Serializable]
    [VerfityAttribute(Id = "VerfityS0003", Name = "选择项目结果为单数/复数选择时抽出", CategoryType = EnumCategoryType.选择, Model = true)]
    public class VerfityS0003 : VerfityOneResult
    {

        private bool _mullitSelect = true;

        [Category("选择项目结果单数/复数抽出设置"), Description("设置复选抽出（true）/单选抽出(false)")]
        public bool MullitSelect
        {
            get { return _mullitSelect; }
            set { _mullitSelect = value; }
        }

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;

            if (entryCommon == "30"  )
            {
                return false;
            }

            if (result == null)
            {
                return false;
            }


            bresult = CheckSpecificCharacter(result, GetSpeicficResult, CheckspecificResult); 

           

            if (bresult)
            {
                System.Console.WriteLine("VerfityS0003");
            }

            return bresult;
        }


        private string GetSpeicficResult(string colResult)
        {
            var splitResult = new Split.SplitEntryResult(ChildImageObject.CategorySetting.DataFormat, colResult);
            if (ChildImageObject.CategorySetting.DataFormat.Contains("sel"))
            {
                return splitResult.GetSelect();
            }
            

            return colResult;
        }


      
        private bool CheckspecificResult(string result)
        {
            bool bresult = false;  

            if (!String.IsNullOrEmpty(result))
            { 
                var resultCount = result.Split(new char[] { '.' }).Count();


                if (MullitSelect)
                {
                    bresult = resultCount > 1;
                }
                else
                {
                    bresult = resultCount <= 1;
                }

            }
            return bresult;
        }


    }
}
